package com.datastructure.recursion.self;

import java.util.Arrays;

public class EightQueue {

    public int max;
    public int [] arrays;

    public EightQueue(int max) {
        this.max = max;
        arrays = new int[max];
    }

    public boolean judge(int n) {
        boolean isRational=true;
        for(int i = 0; i<n;i++){
            if(arrays[n]==arrays[i]||Math.abs(n-i)==Math.abs(arrays[n]-arrays[i])){
                isRational=false;
            }
        }
        return isRational;
    }

    public void arrange(int n){
        if(n==max){
            print();
            return;
        }
        for(int i = 0;i < max;i++){
            arrays[n]=i;
            if(!judge(n)){
                arrange(n+1);
            }
        }
    }

    public void print(){
        System.out.println("当前的array为"+ Arrays.toString(arrays));
    }
    public static void main(String[] args) {

    }


}
